home *** CD-ROM | disk | FTP | other *** search
- Path: cs.uwa.edu.au!jasonb
- From: jasonb@cs.uwa.edu.au (Jason S Birch)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Help me with a basic MUI program PLEASE?
- Date: 10 Jan 96 06:01:26 GMT
- Organization: The University of Western Australia
- Message-ID: <jasonb.821253686@cs.uwa.edu.au>
- References: <2440.6581T1279T1051@in.net>
- NNTP-Posting-Host: decadence.cs.uwa.oz.au
- X-Newsreader: NN version 6.5.0 #3 (NOV)
-
- mave@in.net (John J. Maver) writes:
- > Could someone please help me with MUI? I have started trying to use
- >MUIBuilder,and I can't seem to make a good main.c to control the code it
- >generates. I am new to MUI. All I want to know is how to open the window and
- >then when the person hits the close gadget, have the window close. With my
- >existing main.c. the window opens and is open for good!!
-
- Here's a main program that works with your files. It's a slight
- modification of MUIBuilder/C/Examples/MUIB-Demo.c to make it more
- up-to-date:
-
- /* Libraries */
- #include <libraries/mui.h>
-
- /* Note: If you're using SAS/C, you might prefer to change these
- to <proto/...> and use registerized parameters. */
-
- /* protos */
- #include <clib/muimaster_protos.h>
- #include <clib/alib_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/exec_protos.h>
-
- /* Pragmas */
- #include <pragmas/muimaster_pragmas.h>
- #include <pragmas/exec_pragmas.h>
-
- /* Ansi */
- #include <stdlib.h>
- #include <stdio.h>
-
- /* MUIBuilder */
- #include "test.h"
-
- struct Library * MUIMasterBase;
-
- /* Init function */
- static void init( void )
- {
- if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN)))
- {
- printf("Can't Open MUIMaster Library");
- exit(20);
- }
- }
-
- /* main function */
- main()
- {
- struct ObjApp * App = NULL; /* Application object */
- ULONG signal;
-
- /* Program initialisation (you need to write it yourself) */
- init();
-
- /* Create Application : generated by MUIBuilder */
- if (App = CreateApp()){
-
- /* Your CreateApp() will already open the window for you. If it
- * didn't, you'd have:
- * set(App->WI_label_0, MUIA_Window_Open, TRUE);
- * somewhere here.
- */
-
- /* Set up a notification on the Window's CloseRequest attribute.
- * This attribute is set to TRUE whenever someone clicks on the
- * close gadget. What we're doing here is telling the window to
- * call the app's ReturnID method with the value of ReturnID_Quit,
- * which we'll then check for in our main loop, where we call the
- * NewInput method.
- */
- DoMethod(App->WI_label_0, /* The window */
- MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
- App->App,
- 2,
- MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit
- );
- /* Note that this should be the only ReturnID you use. Earlier
- * examples of MUI programs used ReturnID's for a great deal of
- * work, creating event loops like typical GadTools programs.
- * Avoid this. Instead, create custom classes (it's very, very
- * easy - try to understand PSI.c to learn, along with the
- * Class1.c, Class2.c and Class3.c demos in
- * MUI:Developer/C/Examples) and set up notifications between
- * them.
- * The main event loop should look similar to the following:
- */
- while (DoMethod(App->App, MUIM_Application_NewInput, &signal) != MUIV_Application_ReturnID_Quit) {
- if (signal){ /* Wait for a signal */
- signal = Wait(signal | SIGBREAKF_CTRL_C);
- if (signal & SIGBREAKF_CTRL_C)
- break;
- }
- }
- /* While it's not necessary, you could do a:
- * set(App->WI_label_0, MUIA_Window_Open, FALSE);
- * here to close the window first.
- */
-
- DisposeApp(App);
- } else
- printf("Failed to create application!\n");
-
- CloseLibrary(MUIMasterBase);
- exit(0);
- }
-
- > Is there a good reference for MUI? Some basic examples, not some 18 part
- >multiprogram.
-
- I started by using MUIBuilder to generate some GUIs - the code above
- can be used for pretty much any MUIBuilder interface, now that
- MUIBuilder allows you to set up the notifications - and seeing what
- the result was. Then I moved onto the source code for the demos that
- come with MUI, and finally joined the mui mailing list:
-
- To: listserv@taloa.unice.fr
- Subject:
-
- SIGNON mui
-
- (Or something like that, anyway. :)
-
- > Thank you for your help.
-
- No worries.
-
- ><tsb> John J. Maver
-
- --
- Jason S Birch ,-_|\ email: jasonb@cs.uwa.edu.au
- Department of Computer Science / \ Tel (work): +61 9 380 1840
- The University of Western Australia *_.-._/ Fax (work): +61 9 380 1089
- Nedlands W. Australia 6907 v Tel (home): +61 9 386 8630
-